package com.mindskip.xzs.repository;

import com.mindskip.xzs.domain.TaskExamCustomerAnswer;
import com.mindskip.xzs.repository.base.MyMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface TaskExamCustomerAnswerMapper extends MyMapper<TaskExamCustomerAnswer> {
//    int deleteByPrimaryKey(Integer id);
//
//    int insert(TaskExamCustomerAnswer record);
//
//    int insertSelective(TaskExamCustomerAnswer record);
//
//    TaskExamCustomerAnswer selectByPrimaryKey(Integer id);
//
//    int updateByPrimaryKeySelective(TaskExamCustomerAnswer record);
//
//    int updateByPrimaryKey(TaskExamCustomerAnswer record);

    String queryParams=" id, task_exam_id taskExamId, create_user createUser, create_time createTime, text_content_id textContentId ";

    @Select("select " + queryParams +
            "from t_task_exam_customer_answer\n" +
            "where task_exam_id = #{tid} and create_user=#{uid}\n" +
            "limit 1")
    TaskExamCustomerAnswer getByTUid(@Param("tid") Integer tid, @Param("uid") Integer uid);

    @Select("<script>" +
            "select " + queryParams +
            "from t_task_exam_customer_answer\n" +
            "    where create_user=#{uid} and\n" +
            "    task_exam_id in" +
            " <foreach collection=\"taskIds\" open=\"(\" close=\")\" separator=\",\" item=\"id\">\n" +
            "      #{id}\n" +
            "    </foreach>" +
            "</script>")
    List<TaskExamCustomerAnswer> selectByTUid(@Param("taskIds") List<Integer> taskIds, @Param("uid") Integer uid);
}
